package Model;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Vector;
import Model.Agent;
import Utile.Point;


public class Zone {
	public int color;
	public Integer score;

	public int pz;

	/**
	 * les connaissances communes 
	 * Key : String -posBombe
	 * 				-NbreBombe
	 * 				-NombrePV
	 * 				-NombrePZ
	 */
	public HashMap<String,Vector<?>> conComm;

	public HashMap<Integer,Agent> listAgent;


	public Zone(int c,int p){
		this.color=c;
		this.pz=p;
		this.conComm=new HashMap<String,Vector<?>>();
		this.listAgent=new HashMap<Integer,Agent>();
		this.score = 1000;
	}



	public Zone(int c,int p,int nombre,LinkedList<Point> robot){
		this(c, p);
		int size = robot.size();
		if(c==1){
			for(int i=0;i<size;i++){
				listAgent.put(i,new Agent(this,new Position(robot.get(i).getPosX(), robot.get(i).getPosY()),i));
			}
		}else if(c==2){
			for(int i=0;i<size;i++){
				listAgent.put(Grille.maxrobot+i,new Agent(this,new Position(robot.get(i).getPosX(), robot.get(i).getPosY()),Grille.maxrobot+i));
			}
		}
	}

	public int getColor(){
		return this.color;
	}

	public synchronized int getPZ(){
		return this.pz;
	}

	public synchronized HashMap<String,Vector<?>> getConCom(){
		return this.conComm;
	}

	public HashMap<Integer,Agent> getListAgent(){
		return this.listAgent;
	}

	public int getAgentbyPos(Point p){
		int x = p.getPosX();
		int y = p.getPosY();
		int bon_id=-1;

		for(Agent a : listAgent.values()){
			if((a.pos.getnumX()==x) && (a.pos.getnumY()==y))	bon_id = a.id;	
		}
		return bon_id;
	}

	public synchronized void setPZ(int p){
		this.pz+=p;
	}

}

